package com.example.shutdown_v1.repository;

import com.example.shutdown_v1.entity.SensorBaselineHistory;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 传感器基准值历史记录 Repository
 */
@Repository
public interface SensorBaselineHistoryRepository extends JpaRepository<SensorBaselineHistory, Long> {
    
    /**
     * 根据传感器ID查询历史记录,按创建时间倒序
     */
    List<SensorBaselineHistory> findBySensorIdOrderByCreatedAtDesc(String sensorId);
    
    /**
     * 根据传感器ID和时间范围查询历史记录
     */
    List<SensorBaselineHistory> findBySensorIdAndCreatedAtBetweenOrderByCreatedAtDesc(
            String sensorId, LocalDateTime startTime, LocalDateTime endTime);
    
    /**
     * 根据校准类型查询历史记录
     */
    List<SensorBaselineHistory> findByCalibrationTypeOrderByCreatedAtDesc(String calibrationType);
}

